package com.campus_information_portal.controller;


import com.campus_information_portal.entity.ApplyRecheck;
import com.campus_information_portal.entity.PartyMember;
import com.campus_information_portal.entity.StuApply;
import com.campus_information_portal.service.*;
import com.campus_information_portal.util.Message;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 20155887 赵开兰
 * @className : MarkCheckController
 * @Description ：学生申请成绩复查和老师对复查进行处理的控制层
 * @create 2018/05/22 19:55
 **/
@Controller
@RequestMapping("/markCheck")
@ResponseBody
@CrossOrigin(origins = "*")
public class MarkCheckController {
    @Autowired
    private MarkCheckService markCheckService;

    /**
     * @param :Integer MarkID
     * @Description ：学生申请成绩复查
     * @author 20155887 赵开兰
     * @methodName :ApplyMarkCheck
     * @returnType :Message
     * @create 2018/5/29 11:03
     **/

    @RequestMapping(value = "/applyMarkCheck", method = RequestMethod.GET)
    public Message ApplyMarkCheck(@Param("markID") Integer markID) {
        System.out.println("申请成绩复查进来了");
        System.out.println("前台传过来的原始成绩ID：" + markID);
        //通过成绩ID获取学生ID
        int stuID = markCheckService.queryStuIdByMarkId(markID);
        ApplyRecheck applyRecheck = new ApplyRecheck();
        Date nowDate = new Date();
        applyRecheck.setRescore_apply_state(0);
        applyRecheck.setStu_score_time(nowDate);
        applyRecheck.setMark_id(markID);
        applyRecheck.setStu_info_id(stuID);
        //   SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        System.out.println("---学生申请原始成绩复查------");
        return markCheckService.insertApplyRecheck(applyRecheck);
    }

    /**
     * @param
     * @Description :老师无条件查询所有学生的成绩复查申请记录
     * @author 20155887 赵开兰
     * @methodName
     * @returnType
     * @create 2018/5/27 0:39
     **/

    @RequestMapping(value = "/queryAllMarkChecks", method = RequestMethod.GET)
    public Message queryAllMarkChecks() {
        System.out.println("进入查询成绩复查记录");
        return markCheckService.queryAllMarkChecks();
    }

    /**
     * @param :Integer markCheckId,Integer updateState
     * @Description :老师处理学生复查成绩申请
     * @author 20155887 赵开兰
     * @methodName :markCheckHandel
     * @returnType :Message
     * @create 2018/5/27 13:41
     **/

    @RequestMapping(value = "/markCheckHandel", method = RequestMethod.GET)
    public Message markCheckHandel(@Param("markCheckId") Integer markCheckId, @Param("state") Integer updateState) {
        System.out.println("---markCheckId为:" + markCheckId + "-----updateState为：" + updateState);
        return markCheckService.replyOfApplyScoreRecheck(markCheckId, updateState);
    }


}
